package cn.goodym.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.goodym.mapper.CasePortMapper;
import cn.goodym.po.CasePort;
import cn.goodym.po.Env;
import cn.goodym.po.PagingVO;
import cn.goodym.service.CasePortService;

/**
 * 接口管理服务层
 * 
 * @author Administrator
 * 
 */
@Service("casePortService")
public class CasePortServiceImpl implements CasePortService {

	@Autowired
	private CasePortMapper casePortMapper;

	public int getCount() {
		return casePortMapper.countByExample();
	}

	@Override
	public List<CasePort> findByPaging(Integer toPageNo) {
		PagingVO pagingVO = new PagingVO();
		pagingVO.setToPageNo(toPageNo);
		List<CasePort> list = casePortMapper.findByPaging(pagingVO);

		return list;
	}

	@Override
	public Boolean save(CasePort casePort) {
		CasePort casePorts = casePortMapper
				.selectByPrimaryKey(casePort.getId());
		if (casePorts == null) {
			casePortMapper.insert(casePort);
			return true;
		}
		return false;
	}

	@Override
	public void removeById(Integer id) {
		casePortMapper.deleteByPrimaryKey(id);
	}

	@Override
	public CasePort findById(Integer id) {
		return casePortMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<CasePort> findByName(String name) {
		List<CasePort> list = casePortMapper.selectByExample(name);
		return list;
	}

	@Override
	public void updateById(CasePort casePort) {
		casePortMapper.updateByPrimaryKey(casePort);
	}

	@Override
	public List<CasePort> findAll() {
		return casePortMapper.findAll();
	}

	@Override
	public List<CasePort> findByIdList(Integer parseInt) {
		List<CasePort> list = casePortMapper.findByIdList(parseInt);
		return list;
	}

	@Override
	public CasePort findByItemId(Integer itemId) {
		return casePortMapper.selectByItemId(itemId);
	}

	@Override
	public List<CasePort> findByItemIdList(Integer parseInt) {
		List<CasePort> list = casePortMapper.findByItemIdList(parseInt);
		return list;
	}

}
